package com.arceus.leetcode.dytedance;

import java.util.HashSet;
import java.util.Set;

/**
 * @author : iron
 * @version : 1.0.0
 * @date : 10:57 AM 2018/12/27
 */

public class T1 {


    public static void main(String[] args) {
        String s = " ";
        System.out.println(lengthOfLongestSubstring(s));
    }
    public static int lengthOfLongestSubstring(String s) {
        if(s.length()==1){
            return 1;
        }
        char[] chars = s.toCharArray();
        Set<Character> res = new HashSet<>();

        int length = 0;
        for (int i = 0; i < chars.length; i++) {
            for (int b = i; b < chars.length; b++) {
                if (!res.contains(chars[b])) {
                    res.add(chars[b]);
                } else {
                    length = length > res.size() ? length : res.size();
                    res.clear();
                    break;
                }
            }
        }
        return length;
    }
}
